************************************************************************************************************************
* Replication Do-File for 
*
* McDaniel Eric, Irfan Nooruddin, and Allyson F. Shortle. 2016.
* "Proud to be an American: How National Pride Shapes Visions of National Identity."
* Journal of Race, Ethnicity, and Politics 1 (1): 145-176.
*
* All models estimated using Stata 16.1.
* Please communicate errors identified to in62@georgetown.edu. Thanks in advance for your help.
************************************************************************************************************************


// NOTE: For convenience, change the working directory below to wherever you've saved the folder
clear // Clear Stata
*cd 


set more off

*******************************************
*******************************************
*******************************************// BEGIN REPLICATION
*******************************************
*******************************************

************************************************************
// REPLICATE TABLE 1 AND ASSOCIATED TEXTUAL DISCUSSION
************************************************************

// NOTE: To replicate these results, you will need to use the TSCS database
clear
use "jrep.gss9604.dta"
desc // Describe the database


// Replicating the first two columns of Table 1
factor leaveusa citizenusa likeusa usabetter allsupport usasport polinfl sportpride milpride together noshame dempride econpride ssspride/*
*/ sciencepride artpride historypride equalpride usacloseness, factor(2) pcf

// Replicating the third column of Table 1
factor polinfl dempride econpride sciencepride, pcf fa(1)
estat factors, fac(1) det
rotate, promax(1)
*predict patriotism_fe if e(sample)
alpha polinfl dempride econpride sciencepride
summ patriotism_fe
summ patriotism_fe_rescale

factor dempride econpride sciencepride polinfl if yr2004==0, pcf fa(1)
estat factors, fac(1) det
factor dempride econpride sciencepride polinfl if yr2004==1, pcf fa(1)
estat factors, fac(1) det

*gen patriotism_fe_rescale96 = patriotism_fe_rescale*yr1996
*gen patriotism_fe_rescale04 = patriotism_fe_rescale*yr2004


// Replicating the fourth column of Table 1
factor citizenusa likeusa usabetter, pcf fa(1)
estat factors, fac(1) det
rotate, promax(1)
*predict nationalism_fe if e(sample)
alpha citizenusa likeusa usabetter
summ nationalism_fe
summ nationalism_fe_rescale

factor citizenusa likeusa usabetter if yr2004==0, pcf fa(1)
estat factors, fac(1) det
factor citizenusa likeusa usabetter if yr2004==1, pcf fa(1)
estat factors, fac(1) det

*gen nationalism_fe_rescale96 = nationalism_fe_rescale*yr1996
*gen nationalism_fe_rescale04 = nationalism_fe_rescale*yr2004


// Replicating the correlation coefficient reported in Table 1
corr nationalism_fe_rescale patriotism_fe_rescale


// Replicating the t-tests reported below Table 1 on page 157
sort year
ttest nationalism_fe_rescale if white==1&hypothetical==., by(year)
ttest patriotism_fe_rescale if white==1&hypothetical==., by(year)


************************************************************
// REPLICATE TABLE 2
************************************************************

// NATIVISM
alpha ambornin_recoded_recoded amchrstn_recoded_recoded amlived_recoded_recoded if white==1
summ nativism_pcf1 if white==1
tab1 ambornin_recoded_recoded amchrstn_recoded_recoded amlived_recoded_recoded if white==1&year==1996
tab1 ambornin_recoded_recoded amchrstn_recoded_recoded amlived_recoded_recoded if white==1&year==2004
factor ambornin_recoded_recoded amchrstn_recoded_recoded amlived_recoded_recoded if white==1, pcf fa(1)

// ASSIMILATIONALISM
alpha amenglsh_recoded amfeel_recoded amcit_recoded if white==1
summ assimilate_pcf1 if white==1
tab1 amenglsh_recoded amfeel_recoded amcit_recoded if white==1&year==1996
tab1 amenglsh_recoded amfeel_recoded amcit_recoded if white==1&year==2004
factor amenglsh_recoded amfeel_recoded amcit_recoded, pcf fa(1)

// Replicating the correlation coefficient reported in the note to Table 2 
corr nativism_pcf1 assimilate_pcf1

************************************************************
// REPLICATE TABLE 3
************************************************************

reg nativism_pcf1_rescale female degree incomecat granborn foreign16 south locale republican nationalism_fe_rescale96 /*
*/ patriotism_fe_rescale96 nationalism_fe_rescale04 patriotism_fe_rescale04 yr2004 if white==1&hypothetical==., r

reg assimilate9604 female degree incomecat granborn foreign16 south locale republican nationalism_fe_rescale96 /*
*/ patriotism_fe_rescale96 nationalism_fe_rescale04 patriotism_fe_rescale04 yr2004 if white==1&hypothetical==., r

************************************************************
// REPLICATE TABLE 4
************************************************************

oprobit ambornin_recoded female degree incomecat granborn foreign16 south locale republican nationalism_fe_rescale96 patriotism_fe_rescale96 /*
*/ nationalism_fe_rescale04 patriotism_fe_rescale04 yr2004 /*
*/ if white==1&hypothetical==., r
fitstat

oprobit amchrstn_recoded female degree incomecat granborn foreign16 south locale republican nationalism_fe_rescale96 patriotism_fe_rescale96 /*
*/ nationalism_fe_rescale04 patriotism_fe_rescale04 yr2004 /*
*/ if white==1&hypothetical==., r
fitstat

oprobit amlived_recoded female degree incomecat granborn foreign16 south locale republican nationalism_fe_rescale96 patriotism_fe_rescale96 /*
*/ nationalism_fe_rescale04 patriotism_fe_rescale04 yr2004 /*
*/ if white==1&hypothetical==., r
fitstat

oprobit amenglsh_recoded female degree incomecat granborn foreign16 south locale republican nationalism_fe_rescale96 patriotism_fe_rescale96 /*
*/ nationalism_fe_rescale04 patriotism_fe_rescale04 yr2004 /*
*/ if white==1&hypothetical==., r
fitstat

oprobit amfeel_recoded female degree incomecat granborn foreign16 south locale republican nationalism_fe_rescale96 patriotism_fe_rescale96 /*
*/ nationalism_fe_rescale04 patriotism_fe_rescale04 yr2004 /*
*/ if white==1&hypothetical==., r
fitstat

oprobit amcit_recoded female degree incomecat granborn foreign16 south locale republican nationalism_fe_rescale96 patriotism_fe_rescale96 /*
*/ nationalism_fe_rescale04 patriotism_fe_rescale04 yr2004 /*
*/ if white==1&hypothetical==., r
fitstat


// END
